package com.yurun.controller.admin;

import com.yurun.entity.OperationLog;
import com.yurun.model.vo.Result;
import com.yurun.service.OperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class OperationLogController {
    @Autowired
    OperationLogService operationLogService;
    /**
     * @Description: 添加操作日志
     * @Param: log
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @PostMapping("/operationlog")
    public Result addOperationLog(@RequestBody OperationLog log){
        operationLogService.addOperationLog(log);
        return Result.ok("添加操作日志成功");
    }
    /**
     * @Description: 通过ID-删除操作日志
     * @Param: id
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @DeleteMapping("/operationlog/id")
    public Result deleteOperationLogById(@RequestParam Long id){
        operationLogService.deleteOperationLogById(id);
        return Result.ok("删除操作日志成功");
    }
    /**
     * @Description: 通过日期-获取操作列表
     * @Param: startDate
	 * @Param:  endDate
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("/operationloglist/date")
    public Result getOperationLogListByDate(@RequestParam String startDate,
                                            @RequestParam String endDate){
        List<OperationLog> object=operationLogService.getOperationLogListByDate(startDate, endDate);
        return Result.ok("获取操作日志列表成功",object);
    }
}
